package java3_31;

import java.io.*;


/**
 *7：一个模板文件wuliu. template的内容如下：
 *您的运单号为{danhao}的快件已到达{weizhi},请根据提取码{tiquma}提取，感谢您的支持
 *请把上面{}内的内容（包括{})替换为具体的信息，将替换后的内容写入到 《物流.txt》中
 */
public class Homework7 {
    public static void main(String[] args) {
        try {
            InputStream inputStream = new FileInputStream("G:\\JAVA84\\wuliu.template");
            BufferedReader br = new BufferedReader(new InputStreamReader(inputStream, "GBK"));

            BufferedWriter bw = new BufferedWriter(new FileWriter("G:\\JAVA84\\物流.txt"));
            String line = null;
            StringBuffer stringBuffer = new StringBuffer();
            while ((line = br.readLine())!=null){
                stringBuffer.append(line);
            }
            String writeString = stringBuffer.toString();
             writeString = writeString.replace("{danhao}","xxx1123");
             writeString = writeString.replace("{weizhi}","火星");
             writeString = writeString.replace("{tiquma}","123");

            bw.write(writeString,0,writeString.length());
            bw.flush();
            br.close();
            bw.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
